<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
    <style>
        .active {
            background-color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <hello-age :list="fruits">
            <span :class="listFruit.fruitList.id === 2 ?'active':''" slot-scope="listFruit">{{listFruit.fruitList.id}}</span>
        </hello-age>
    </div>
    <script>
        Vue.component('hello-age', {
            props: ['list'],
            data: function() {
                return {
                    name: 'Tom'
                }
            },
            // 作用域插槽：一般指父组件获取到子组建的数据，然后对子组件进行相应的修改
            template: `
            <div>
               <ul>
               <li v-for="item in list" :key="item.id">
                 <slot :fruitList="item"></slot>
               </li>
               </ul>
            </div>
            `

        })
        var vm = new Vue({
            el: '#app',
            data: {
                fruits: [{
                    id: 1,
                    name: 'apple'
                }, {
                    id: 2,
                    name: 'pear'
                }, {
                    id: 3,
                    name: 'banner'
                }]
            }
        })
    </script>
</body>

</html>